# -*- coding: utf-8 -*-

import scrapy

from douban.items import DoubanItem


class DoubandianyingSpider(scrapy.Spider):
    name = 'doubandianying'
    allowed_domains = ['jobbole.com']


    def start_requests(self):
        urls = [
            'http://blog.jobbole.com/tag/database/',
        ]
        for url in urls:
            yield scrapy.Request(url=url, callback=self.parse)


    def parse(self, response):
        a = response.css("div.post-meta  a.archive-title")
        title = a.attrib.get("title", None)
        url = a.attrib.get("href", None)
        print(title, url)
        item = DoubanItem(title=title, url=url)
        yield item

